package com.crux.hbase.demo.controller;

import com.crux.hbase.demo.dao.OperationLogRepository;
import com.crux.hbase.demo.entity.OperationLog;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/api/operationlog")
public class DemoController {
    private final OperationLogRepository operationLogRepository;

    public DemoController(OperationLogRepository operationLogRepository) {
        this.operationLogRepository = operationLogRepository;
    }

    @GetMapping("/findall")
    public List<OperationLog> findAll() {
        List<OperationLog> operationLogs = new ArrayList<>();
        operationLogRepository.findAll().forEach(operationLog -> operationLogs.add(operationLog));
        return operationLogs;
    }
}

